<template>
	<view class="cantainer">
		<fui-card  :title="thisGreenLand.name" size="35">
			<view class="fui-card__content">
				<my-swiper :list="swiperList"></my-swiper>
			</view>
		</fui-card>
		<fui-card >
			<view class="fui-card__content">
				<view class="text-content">
					<view class="text-title">
						<text>绿地名称： <text v-text="thisGreenLand.name"></text></text>
					</view>
					<view class="text-title">
						<text>网格编号： <text v-text="thisGreenLand.interNum"></text></text>
					</view>
					<view class="text-title">
						<text>上传时间： <text v-text="thisGreenLand.date"></text></text>
					</view>
				
					
				</view>
				<view class="split">
					<view class="color"> &nbsp;</view>预警信息
				</view>
				<view class="risk">
					<text>当前等级预警度值：</text>
					<view v-if="thisGreenLand.waringGrade==0" class="risk-img-0"></view>
					<view v-if="thisGreenLand.waringGrade==1" class="risk-img-1"></view>
					<view v-if="thisGreenLand.waringGrade==2" class="risk-img-2"></view>
					<view v-if="thisGreenLand.waringGrade==3" class="risk-img-3"></view>
					<view v-if="thisGreenLand.waringGrade==4" class="risk-img-3"></view>
					
				</view>
				<view class="risk">
					<text>R值：</text>
					<input type="number" :value="thisGreenLand.rvalue"  :disabled="true"/>
				</view>
			</view>
		</fui-card>


	</view>
	
</template>

<script>
	import {saveImageToPhotosAlbum} from "../../common/utils/saveImage.js"
	export default {
		data() {
			return {
				swiperList:[],
				user:[],
				thisGreenLand:[],
				
			}
		},
		
		onLoad(options) {
			//page/messageUp/messageUp历史信息页面跳转
			if(options.id != null ){
				this.initDate(options.id)
				this.showPhoto()
				
			}
			//pages/riskResponse/riskResponse.vue风险响应页面跳转
			if(options.greenLandId != null){
				// console.log(options.greenLandId)
				this.greenLandDetails(options.greenLandId)
			}
			// console.log(this.thisGreenLand)
		},
		methods: {
			initDate(id){
				if(this.$storage.get("user") != []){
					this.thisGreenLand=[]
					this.user= JSON.parse( this.$storage.get("user"))
					for(let i=0;i<this.user.greenLands.length;i++){
						if(this.user.green[i].interNum == id){
							this.thisGreenLand=this.user.green[i]
							break
						}
					}
				}
			},
			greenLandDetails(id){
				if(this.$storage.get("greenLandAll") != []){
					this.thisGreenLand=[]
					let all = this.$storage.get("greenLandAll")
					
					all.forEach(item=>{
						if(item.id == id){
							// console.log("绿地：")
							// console.log(item)
							this.thisGreenLand=item
							item.greenLandPhotos.forEach(photo=>{
								// console.log(photo);
								this.swiperList.push(photo.photoUrl)
								// console.log(photo.photoUrl)
							})
						}
					})
				}
			},
			showPhoto(){
				this.thisGreenLand.greenLandPhotos.forEach((item,index)=>{
					this.swiperList.push(item.photoUrl)
					// console.log(item.photoUrl)
					// console.log(item)
				})
			}
		}
	}
</script>

<style scoped lang="scss">

.cantainer{
	margin: 20rpx;
}
.fui-cover{
	border-radius: 20px;
	height: 200rpx;
}
.text-content{
	margin-top: 20rpx;
	box-shadow:5 5 5 #000000;
	.text-title{
		margin: 10rpx;
		color: #8b8b8b;
	}
}
.risk{
	color: #8b8b8b;
	display: flex;
	flex-direction: row;
	align-items: center;
	margin-bottom: 50rpx;
}
.risk-img-0{
		width: 100rpx;
		height: 200rpx;
		background:linear-gradient(180deg, #00ff55 0%, #016f29 100%);
		border-radius: 20rpx;
}
.risk-img-1{
		width: 100rpx;
		height: 200rpx;
		background:linear-gradient(180deg, #00ffff 0%, #005a5a 100%);
		border-radius: 20rpx;
}
.risk-img-2{
		width: 100rpx;
		height: 200rpx;
		background:linear-gradient(180deg, #ebff07 0%, #6f4502 100%);
		border-radius: 20rpx;
}
.risk-img-3{
		width: 100rpx;
		height: 200rpx;
		background:linear-gradient(180deg, #ff5500 0%, #7a5100 100%);
		border-radius: 20rpx;
}
.risk-img-4{
		width: 100rpx;
		height: 200rpx;
		background:linear-gradient(180deg, #ff0a0a 0%, #6f0000 100%);
		border-radius: 20rpx;
}
.split{
	margin: 50rpx 20rpx;
	color:#3b4244 ;
	font-weight: bold;
	.color{
		display: inline-block;
		width: 8rpx;
		height: 25rpx;
		background-color: #348669;
		margin-right: 5rpx;
	}
}



</style>
